package com.microboot.controller;

import com.microboot.entity.common.dto.Result;
import com.microboot.entity.product.dto.ProductReqsVO;
import com.microboot.entity.product.dto.ProductRespVO;
import com.microboot.entity.user.dto.UserReqsVO;
import com.microboot.entity.user.dto.UserRespVO;
import com.microboot.service.ProductService;
import com.microboot.service.UserInfoService;
import com.microboot.service.WeatherWebService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户信息控制器
 * @author longxian
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/user")
public class UserInfoController {

    private final UserInfoService userInfoService;
    private final ProductService productService;
    private final WeatherWebService weatherWebService;

    @PostMapping(value = "/getUserInfo")
    public Result<UserRespVO> getUserInfo(@RequestBody UserReqsVO userReqsVO) {
        UserRespVO userInfo = userInfoService.getUserInfo(userReqsVO.getName());
        //return Result.success(BeanUtil.copyProperties(dao.getById(id), AdminMsgViewResp.class));
        return Result.success(userInfo);
    }

    @PostMapping(value = "/getProductInfo")
    public Result<ProductRespVO> getProductInfo(@RequestBody ProductReqsVO productReqsVO) {
        ProductRespVO productInfo = productService.getProductInfo(productReqsVO);
        //return Result.success(BeanUtil.copyProperties(dao.getById(id), AdminMsgViewResp.class));
        return Result.success(productInfo);
    }

    @PostMapping(value = "/getSupportCity")
    public Result<List<String>> getSupportCity(@RequestBody ProductReqsVO productReqsVO) {
        List<String> cityList = weatherWebService.getWsdl2JavaSupportCity();
        //return Result.success(BeanUtil.copyProperties(dao.getById(id), AdminMsgViewResp.class));
        return Result.success(cityList);
    }

}
